
package org.drip.historical.attribution;

/*
 * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
 */

/*!
 * Copyright (C) 2016 Lakshmi Krishnamurthy
 * 
 *  This file is part of DRIP, a free-software/open-source library for fixed income analysts and developers -
 * 		http://www.credit-trader.org/Begin.html
 * 
 *  DRIP is a free, full featured, fixed income rates, credit, and FX analytics library with a focus towards
 *  	pricing/valuation, risk, and market making.
 * 
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *   	you may not use this file except in compliance with the License.
 *   
 *  You may obtain a copy of the License at
 *  	http://www.apache.org/licenses/LICENSE-2.0
 *  
 *  Unless required by applicable law or agreed to in writing, software
 *  	distributed under the License is distributed on an "AS IS" BASIS,
 *  	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  
 *  See the License for the specific language governing permissions and
 *  	limitations under the License.
 */

/**
 * FixFloatMarketSnap contains the Metrics Snapshot associated with the relevant Manifest Measures for the
 *  given Fix Float Swap Position.
 *
 * @author Lakshmi Krishnamurthy
 */

public class FixFloatMarketSnap extends org.drip.historical.attribution.PositionMarketSnap {

	/**
	 * FixFloatMarketSnap Constructor
	 * 
	 * @param dtSnap The Snapshot Date
	 * @param dblMarketValue The Snapshot Market Value
	 * 
	 * @throws java.lang.Exception Thrown if the Inputs are Invalid
	 */

	public FixFloatMarketSnap (
		final org.drip.analytics.date.JulianDate dtSnap,
		final double dblMarketValue)
		throws java.lang.Exception
	{
		super (dtSnap, dblMarketValue);
	}

	/**
	 * Set the Swap Rate and Position Sensitivity
	 * 
	 * @param dblSwapRate The Swap Rate
	 * @param dblSwapRateSensitivity The Position Swap Rate Sensitivity
	 * @param dblSwapRateRollDown The Position Swap Rate Roll Down
	 * 
	 * @return TRUE => The Swap Rate and the Position Sensitivity successfully set
	 */

	public boolean setSwapRateMarketFactor (
		final double dblSwapRate,
		final double dblSwapRateSensitivity,
		final double dblSwapRateRollDown)
	{
		return addManifestMeasureSnap ("SwapRate", dblSwapRate, dblSwapRateSensitivity, dblSwapRateRollDown);
	}

	/**
	 * Set the Maturity Date
	 * 
	 * @param dtMaturity The Maturity Date
	 * 
	 * @return TRUE => The Maturity Date successfully set
	 */

	public boolean setMaturityDate (
		final org.drip.analytics.date.JulianDate dtMaturity)
	{
		return setDate ("MaturityDate", dtMaturity);
	}

	/**
	 * Retrieve the Maturity Date
	 * 
	 * @return The Maturity Date
	 */

	public org.drip.analytics.date.JulianDate maturityDate()
	{
		return date ("MaturityDate");
	}

	/**
	 * Set the Reset Date
	 * 
	 * @param dtReset The Reset Date
	 * 
	 * @return TRUE => The Reset Date successfully set
	 */

	public boolean setResetDate (
		final org.drip.analytics.date.JulianDate dtReset)
	{
		return setDate ("ResetDate", dtReset);
	}

	/**
	 * Retrieve the Reset Date
	 * 
	 * @return The Reset Date
	 */

	public org.drip.analytics.date.JulianDate resetDate()
	{
		return date ("ResetDate");
	}

	/**
	 * Set the Floater Label
	 * 
	 * @param strFloaterLabel Floater Label
	 * 
	 * @return TRUE => The Floater Label successfully set
	 */

	public boolean setFloaterLabel (
		final java.lang.String strFloaterLabel)
	{
		return setC1 ("FloaterLabel", strFloaterLabel);
	}

	/**
	 * Retrieve the Floater Label
	 * 
	 * @return The Floater Label
	 */

	public java.lang.String floaterLabel()
	{
		return c1 ("FloaterLabel");
	}

	/**
	 * Set the Initial Fair Premium
	 * 
	 * @param dblInitialFairPremium The Initial Fair Premium
	 * 
	 * @return TRUE => The Initial Fair Premium Successfully set
	 */

	public boolean setInitialFairPremium (
		final double dblInitialFairPremium)
	{
		return setR1 ("InitialFairPremium", dblInitialFairPremium);
	}

	/**
	 * Retrieve the Initial Fair Premium
	 * 
	 * @return The Initial Fair Premium
	 * 
	 * @throws java.lang.Exception Thrown if the Initial Fair Premium cannot be obtained
	 */

	public double initialFairPremium()
		throws java.lang.Exception
	{
		return r1 ("InitialFairPremium");
	}

	/**
	 * Set the Current Fair Premium
	 * 
	 * @param dblCurrentFairPremium The Current Fair Premium
	 * 
	 * @return TRUE => The Current Fair Premium Successfully Set
	 */

	public boolean setCurrentFairPremium (
		final double dblCurrentFairPremium)
	{
		return setR1 ("CurrentFairPremium", dblCurrentFairPremium);
	}

	/**
	 * Retrieve the Current Fair Premium
	 * 
	 * @return The Current Fair Premium
	 * 
	 * @throws java.lang.Exception Thrown if the Current Fair Premium cannot be obtained
	 */

	public double currentFairPremium()
		throws java.lang.Exception
	{
		return r1 ("CurrentFairPremium");
	}

	/**
	 * Set the Fixed Coupon
	 * 
	 * @param dblFixedCoupon The Fixed Coupon
	 * 
	 * @return TRUE => The Fixed Coupon Successfully Set
	 */

	public boolean setFixedCoupon (
		final double dblFixedCoupon)
	{
		return setR1 ("FixedCoupon", dblFixedCoupon);
	}

	/**
	 * Retrieve the Fixed Coupon
	 * 
	 * @return The Fixed Coupon
	 * 
	 * @throws java.lang.Exception Thrown if the Fixed Coupon cannot be obtained
	 */

	public double fixedCoupon()
		throws java.lang.Exception
	{
		return r1 ("FixedCoupon");
	}

	/**
	 * Set the Clean Fixed DV01
	 * 
	 * @param dblCleanFixedDV01 The Clean Fixed DV01
	 * 
	 * @return TRUE => The Clean Fixed DV01 Successfully Set
	 */

	public boolean setCleanFixedDV01 (
		final double dblCleanFixedDV01)
	{
		return setR1 ("CleanFixedDV01", dblCleanFixedDV01);
	}

	/**
	 * Retrieve the Clean Fixed DV01
	 * 
	 * @return The Clean Fixed DV01
	 * 
	 * @throws java.lang.Exception Thrown if the Clean Fixed DV01 cannot be obtained
	 */

	public double cleanFixedDV01()
		throws java.lang.Exception
	{
		return r1 ("CleanFixedDV01");
	}

	/**
	 * Set the Reset Rate
	 * 
	 * @param dblResetRate The Reset Rate
	 * 
	 * @return TRUE => The Reset Rate Successfully Set
	 */

	public boolean setResetRate (
		final double dblResetRate)
	{
		return setR1 ("ResetRate", dblResetRate);
	}

	/**
	 * Retrieve the Reset Rate
	 * 
	 * @return The Reset Rate
	 * 
	 * @throws java.lang.Exception Thrown if the Reset Rate cannot be obtained
	 */

	public double resetRate()
		throws java.lang.Exception
	{
		return r1 ("ResetRate");
	}

	/**
	 * Set the Roll Down Fair Premium
	 * 
	 * @param dblRollDownFairPremium The Roll Down Fair Premium
	 * 
	 * @return TRUE => The Roll Down Fair Premium Successfully Set
	 */

	public boolean setRollDownFairPremium (
		final double dblRollDownFairPremium)
	{
		return setR1 ("RollDownFairPremium", dblRollDownFairPremium);
	}

	/**
	 * Retrieve the Roll Down Fair Premium
	 * 
	 * @return The Roll Down Fair Premium
	 * 
	 * @throws java.lang.Exception Thrown if the Roll Down Fair Premium cannot be obtained
	 */

	public double rollDownFairPremium()
		throws java.lang.Exception
	{
		return r1 ("RollDownFairPremium");
	}

	/**
	 * Set the Accrued
	 * 
	 * @param dblAccrued The Accrued
	 * 
	 * @return TRUE => The Accrued successfully set
	 */

	public boolean setAccrued (
		final double dblAccrued)
	{
		return setR1 ("Accrued", dblAccrued);
	}

	/**
	 * Retrieve the Accrued
	 * 
	 * @return The Accrued
	 * 
	 * @throws java.lang.Exception Thrown if the Accrued cannot be obtained
	 */

	public double accrued()
		throws java.lang.Exception
	{
		return r1 ("Accrued");
	}

	@Override public java.lang.String toString()
	{
		try {
			return "\t[Date: " + snapDate() + "; Maturity Date: " + maturityDate() + "; Floater Label: " +
				floaterLabel() + "; Market Value:" + org.drip.quant.common.FormatUtil.FormatDouble
					(marketValue(), 1, 8, 1) + "; DV01:" + org.drip.quant.common.FormatUtil.FormatDouble
						(cleanFixedDV01(), 1, 8, 1) + "; Reset Rate:" +
							org.drip.quant.common.FormatUtil.FormatDouble (resetRate(), 1, 8, 1) +
								"; Reset Date: " + resetDate() + "; Initial Fair Premium: " +
									org.drip.quant.common.FormatUtil.FormatDouble (initialFairPremium(), 1,
										8, 1) + "; Current Fair Premium: " +
											org.drip.quant.common.FormatUtil.FormatDouble
												(currentFairPremium(), 1, 8, 1);
		} catch (java.lang.Exception e) {
			e.printStackTrace();
		}

		return "";
	}
}
